import java.util.*;
//
// IUT de Nice / Departement informatique / Module APO Java
// Annee 2011_2012 - Himalaya
//
// Classe T_Plateau_N4 - Tests unitaires des methodes placerRessource et placerCommande
//
// Auteur : A.Marongiu et S.Guery
//

public class T_Plateau_N4 {

   public static void main (String[] args) {	
	   Tests.Begin("Himalaya.Plateau", "1.0.4");
		 //--- Village	
		   	LinkedList<Ressource> listR = new LinkedList<Ressource>();
			Commande cmd = new Commande();
	
			Village village1 = null;
			Village village2 = null;
			Village village3 = null;
			try {
				village1 = new Village(1,1,"",cmd,false,listR);
				village2 = new Village(2,1,"",cmd,false,listR);
				village3 = new Village(3,1,"",cmd,false,listR);
			} catch (Throwable e) {
				e.printStackTrace();
			}
	
			Village[] tabVillage = new Village[3];
			
			tabVillage[0] = village1;
			tabVillage[1] = village2;
			tabVillage[2] = village3;
			
		// --- Sentiers
			Sentier sentier1 = new Sentier("terre",village1,village2);
			Sentier sentier2 = new Sentier("pierre", village2,village3);
			Sentier sentier3 = new Sentier("glace",village3,village1);
	
			Sentier matSentiers[][] = new Sentier[4][4];
			
			matSentiers[1][2] = sentier1; 
			matSentiers[2][3] = sentier2; 	
			matSentiers[3][1] = sentier3; 	
					
		// --- Regions
			ArrayList<Village> villagesR1 = new ArrayList<Village>();
			villagesR1.add(village1);
			villagesR1.add(village2);
			ArrayList<Village> villagesR2 = new ArrayList<Village>();
			villagesR2.add(village2);
			villagesR2.add(village3);
			ArrayList<Village> villagesR3 = new ArrayList<Village>();
			villagesR3.add(village3);
			villagesR3.add(village1);
			
			Region region1 = new Region(1,0,villagesR1);
			Region region2 = new Region(2,0,villagesR2);
			Region region3 = new Region(3,0,villagesR3);
	
			HashMap<Integer,Region>  HmapRegions = new HashMap<Integer,Region>();
	
			HmapRegions.put(new Integer(1),region1);
			HmapRegions.put(new Integer(2),region2);
			HmapRegions.put(new Integer(3),region3);
	
			Plateau p = new Plateau(tabVillage,matSentiers,HmapRegions);
			
	         Tests.Design("Controle de la methode placerRessource", 3); {
	
	            Tests.Case("cas d'une ressource vide"); {
	            	Ressource r= new Ressource();
	            	p.placerRessource(r,3);
	            	
	            	Tests.Unit("numero du village : 3\n"
								 + " niveau religieux : 1\n"
						  		 + " couleur stupa : \n"
								 + "jour de marche : false\n"
								 + "[Ressource [nom=, valeur=0]]", (p.getVillages())[3-1].toString());
	            }
	            
	            Tests.Case("cas d'une ressource normale"); {
	            	Ressource jade = new Ressource("jade",4);
	            	p.placerRessource(jade,3);
	            	
	            	Tests.Unit("numero du village : 3\n"
								 + " niveau religieux : 1\n"
						  		 + " couleur stupa : \n"
								 + "jour de marche : false\n"
								 + "[Ressource [nom=, valeur=0], Ressource [nom=jade, valeur=4]]", (p.getVillages())[3-1].toString());
	            }
	         }
	         Tests.Design("Controle de la methode placerCommande", 3); {
	
	             Tests.Case("cas d'une commande vide"); {	
	            	 Commande c = new Commande();   	
	            	 p.placerCommande(c, 1);
		            	 
	            	 Tests.Unit("numero du village : 1\n"
								+ " niveau religieux : 1\n"
								+ " couleur stupa : \n" 
								+ "jour de marche : false\n"
								+ "[Ressource [nom=, valeur=0], Ressource [nom=jade, valeur=4]]", (p.getVillages())[1-1].toString());
	             }
	             
	             Tests.Case("cas d'une commande normale"); {	              	 
	            	 Ressource or = new Ressource("or",5);
	            	 ArrayList<Ressource> a = new ArrayList<Ressource>();
	            	 a.add(or);
	            	 Commande c2 = new Commande(2,2,a);
	            	 
	            	 p.placerCommande(c2, 2);
	            
	            	 Tests.Unit("numero du village : 2\n"
	            			 + " niveau religieux : 1\n"
	            			 + " couleur stupa : \n" 
	            			 + "jour de marche : false\n"
	            			 + "[Ressource [nom=, valeur=0], Ressource [nom=jade, valeur=4]]", (p.getVillages())[2-1].toString());
	             }
	          }
         
      Tests.End();       
   }
}
